package gui;

import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.ImageIcon;

public class JFrameStudentMainPage extends JFrame {

	private JPanel contentPane;
	public static String ID;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					JFrameStudentMainPage frame = new JFrameStudentMainPage();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public JFrameStudentMainPage() {
		setTitle("Student - Main page");
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 550, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		JLabel lblTeacherMenu = new JLabel("Student Menu");
		lblTeacherMenu.setHorizontalAlignment(SwingConstants.CENTER);
		lblTeacherMenu.setFont(new Font("Tahoma", Font.BOLD, 30));
		lblTeacherMenu.setBounds(125, 10, 300, 50);
		contentPane.add(lblTeacherMenu);

		JButton btnAttemptQuiz = new JButton("Attempt Quiz");
		btnAttemptQuiz.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				JFrameStudentAttemptQuiz jFrameStudentAttemptQuiz = new JFrameStudentAttemptQuiz();
				jFrameStudentAttemptQuiz.setVisible(true);
				dispose();
			}
		});
		btnAttemptQuiz.setFont(new Font("Tahoma", Font.PLAIN, 18));
		btnAttemptQuiz.setBounds(150, 80, 250, 60);
		contentPane.add(btnAttemptQuiz);

		JButton btnViewMyResult = new JButton("View My Result");
		btnViewMyResult.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				JFrameStudentViewResult jFrameStudentViewResult = new JFrameStudentViewResult();
				jFrameStudentViewResult.setVisible(true);
				dispose();
			}
		});
		btnViewMyResult.setFont(new Font("Tahoma", Font.PLAIN, 18));
		btnViewMyResult.setBounds(150, 180, 250, 60);
		contentPane.add(btnViewMyResult);

		JButton btnSignOut = new JButton("");
		btnSignOut.setIcon(new ImageIcon("resource\\btn_signout.png"));
		btnSignOut.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				if (JOptionPane.showConfirmDialog(JFrameStudentMainPage.this,
						"Do you want to sign out?", "Confirm",
						JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {

					JFrameLogin jFrameLogin = new JFrameLogin();
					jFrameLogin.setVisible(true);
					dispose();
				}
			}
		});
		btnSignOut.setFont(new Font("Tahoma", Font.PLAIN, 18));
		btnSignOut.setBounds(450, 20, 50, 50);
		contentPane.add(btnSignOut);
	}

}
